home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / mint / mgr / mgrdemos.zoo / demo / sh / showfont < prev    next >
Encoding:
Text File  |  1989-01-24  |  2.5 KB  |  122 lines

  1. #!/bin/sh
  2. #                        Copyright (c) 1987 Bellcore
  3. #                            All Rights Reserved
  4. #       Permission is granted to copy or use this program, EXCEPT that it
  5. #       may not be sold for profit, the copyright notice must be reproduced
  6. #       on copies, and credit should be given to Bellcore where it is due.
  7. #       BELLCORE MAKES NO WARRANTY AND ACCEPTS NO LIABILITY FOR THIS PROGRAM.
  8.  
  9. #    $Header: showfont,v 4.1 88/06/21 14:01:39 bianchi Exp $
  10. #    $Source: /tmp/mgrsrc/demo/sh/RCS/showfont,v $
  11.  
  12. #    show all of the fonts
  13.  
  14. usage="Usage:  `basename $0` [ -s'string' ] [ -c ] [ -i ] [ -number ] [ font-files ... ]
  15. Show the fonts found in the given fonts-files.
  16. -s'string'    Change the string used as the example of the font.
  17. -c    Show current font.
  18. -i    Show internal fonts, by number.
  19. "
  20.  
  21. ESC=^[
  22. string='abcdefghijklmnopqrstuvwxyz
  23. ABCDEFGHIJKLMNOPQRSTUVWXYZ
  24. 1234567890 !@#$%^&*()_+|~ -=\`
  25. {}[] :";'\'' <>? ,./'
  26.  
  27. if /bin/test $TERM != mgr
  28. then
  29.     echo "$0 only works on mgr terminals"
  30.     exit 1
  31. fi
  32.  
  33. if [ $# -lt 1 ]
  34. then
  35.     echo >&2 "${usage}"
  36.     exit 255
  37. fi
  38.  
  39. trap 'exit' 1 2 15
  40. trap 'stty echo' 0
  41.  
  42. stty -echo
  43.  
  44. #    get current font info.
  45. echo "${ESC}3I"
  46. read charwide charhigh curnum curname
  47.  
  48. trap '
  49.     len=`expr length ${curname}`
  50.     echo "${ESC}${curnum},${len}F${curname}"
  51.     echo "${ESC}${curnum}F"
  52.     stty echo
  53.     ' 0
  54.  
  55. while [ -n "$1" ]
  56. do
  57.     case $1 in
  58.     -c )
  59.         echo "${ESC}0FCurrent font ${curnum}, ${curname}${ESC}${curnum}F
  60. ${string}
  61. "
  62.         ;;
  63.     -i )
  64.         echo ${ESC}0F${ESC}3I
  65.         read charwide charhigh num name
  66.         echo "${ESC}0FFont ${num} ${name} ${ESC}${num}F
  67. ${string}
  68. ${ESC}0F"
  69.  
  70.         count=1
  71.         while    echo ${ESC}${count}F${ESC}3I
  72.             read charwide charhigh num name
  73.             test ${num} != 0
  74.         do
  75.             echo "${ESC}0FFont ${num} ${name} ${ESC}${num}F
  76. ${string}
  77. ${ESC}${curnum}F"
  78.             count=`expr ${count} + 1`
  79.         done
  80.         ;;
  81.     -s?* )
  82.         string=`expr "$1" : '-s\(.*\)'`
  83.         ;;
  84.     -[0-9] | -[0-9][0-9] )
  85.         argnum=`expr $1 : '-\(.*\)'`
  86.         echo ${ESC}${argnum}F${ESC}3I
  87.         read charwide charhigh num name
  88.         if [ ${argnum} -ne ${num} ]
  89.         then
  90.             echo >&2 "$0:  No font ${argnum} available."
  91.         else
  92.             echo "${ESC}0FFont ${num} ${name} ${ESC}${num}F
  93. ${string}
  94. ${ESC}${curnum}F"
  95.         fi
  96.         ;;
  97.     -[0-9]* )
  98.         echo >&2 "$0:  Illegal option argument.  '$1'
  99.     -number is limited to 2 digits."
  100.         echo >&2 "${usage}"
  101.         exit 255
  102.         ;;
  103.     -* )
  104.         echo >&2 "$0:  Illegal option argument.  '$1'"
  105.         echo >&2 "${usage}"
  106.         exit 255
  107.         ;;
  108.     * )
  109.         break
  110.     esac
  111.     shift
  112. done
  113.  
  114. for file 
  115. do
  116.     len=`expr length ${file}`
  117.     echo "${ESC}${curnum},${len}F${file}"
  118.     echo "${ESC}0F(font ${file})${ESC}${curnum}F
  119. ${string}
  120. ${ESC}0F"
  121. done
  122.